package cn.edu.nuc.ssm.dao;

import cn.edu.nuc.ssm.entity.AccountTransfer;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface AccountTransferMapper {
    @Delete({
        "delete from account_transfer",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer id);

    @Insert({
        "insert into account_transfer (id,uid, account_in_id, ",
        "account_out_id, transfer_date, ",
        "transfer_money, detail)",
        "values (#{id,jdbcType=INTEGER}, #{uid,jdbcType=INTEGER},#{accountInId,jdbcType=INTEGER}, ",
        "#{accountOutId,jdbcType=INTEGER}, #{transferDate,jdbcType=CHAR}, ",
        "#{transferMoney,jdbcType=DECIMAL}, #{detail,jdbcType=VARCHAR})"
    })
    int insert(AccountTransfer record);

    int insertSelective(AccountTransfer record);

    @Select({
        "select",
        "id, uid,account_in_id, account_out_id, transfer_date, transfer_money, detail",
        "from account_transfer",
        "where id = #{id,jdbcType=INTEGER}"
    })
    @ResultMap("cn.edu.nuc.ssm.dao.AccountTransferMapper.BaseResultMap")
    AccountTransfer selectByPrimaryKey(Integer id);

    int updateByPrimaryKeySelective(AccountTransfer record);

    @Update({
        "update account_transfer",
        "set account_in_id = #{accountInId,jdbcType=INTEGER},",
          "account_out_id = #{accountOutId,jdbcType=INTEGER},",
          "transfer_date = #{transferDate,jdbcType=CHAR},",
          "transfer_money = #{transferMoney,jdbcType=DECIMAL},",
          "detail = #{detail,jdbcType=VARCHAR}",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(AccountTransfer record);

    @Select({
        "select",
        "id, account_in_id, account_out_id, transfer_date, transfer_money, detail",
        "from account_transfer",
        "limit #{start,jdbcType=INTEGER},offset=#{offset,jdbcType=INTEGER}"
    })
    List<AccountTransfer> findListPage(@Param("start") int start,@Param("offset") int offset);


}